<?php  if (!defined('BASEPATH')) exit('No direct script access allowed');

require_once APPPATH . 'models/m_select.php';

/**
 * Модель выборки новостей
 *
 * @package CoreFramework
 * @version 1.0
 * @author Gennadiy Kozlenko
 */
class M_Select_News extends M_Select {
   
   /**
    * Конструктор класса
    *
    * @access public
    * @return M_Select_Menu
    */
   function M_Select_News() {
      parent::M_Select();
      $this->load->helper('content');
      $this->load->helper('text');
      $this->initialize();
   } // end M_Select_Site_Menu
   
   /**
    * Инициализация модельки
    *
    * @access public
    */
   function initialize() {
      // Устанавливаем запрос
      $sql = "
         SELECT
            *
         FROM
            " . $this->db->dbprefix('contents') . "
         WHERE
            status <> 'deleted' AND
            id_menu IN (
               SELECT
                  id_menu
               FROM
                  " . $this->db->dbprefix('menus') . "
               WHERE
                  name IN ('news', 'news_company', 'news_media')
            )
      ";
      parent::set_sql($sql);
      parent::add_sort('datetime', false);
   } // end initialize
   
   /**
    * Установка SQL запроса
    *
    * @access public
    * @param string $table
    */
   function set_sql($sql) {
      
   } // end set_sql
   
   /**
    * Обработка результата
    *
    * @access protected
    * @param array $result
    */
   function _process_result(&$result) {
      $result['link'] = get_url($result);
      $result['content'] = character_limiter(strip_tags($result['content']), 500);
      $result['date'] = mdate($this->config->item('date_format'), $result['datetime']);
   } // end _process_result
   
}
